// component/exam_start/exam_start.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    examSetting:{
      type:Object
    },
    subjectList:{
      type:Array
    },
    isStarted:{
      type: Boolean,
      value:false
    },
    remainTime:{
      type:String
    },
    minutes:{
      type:Number
    },
    subjectType:{
      type:String,
      value:''
    }
    

  },

  ready:function(){

      

  },

  /**
   * 组件的初始数据
   */
  data: {
    

  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
   * 开始考试
   */
    startExam: function () {

     
      var me = this;
      var minutes = this.data.minutes;
      var second = minutes*60;
      var remainTime;
      var timer = setInterval(function () {
        second--;
        
        remainTime = getApp().subjectPage.getRemainTime(second);
        if (second == 0) {
          wx.showToast({
            title: '考试时间到',
          });
          clearInterval(timer);
        } else if (second == 300) {
          wx.showToast({
            title: '距离考试结束还有5分钟',
            duration: 3000
          })
        }

        me.triggerEvent('updateRemainTime', {remainTime:remainTime});

      }, 1000);

      this.setData({ isStarted: true });
      this.triggerEvent('startexam');
      
  

    }

  }
})
